App.AddMenu = function(ds) {
	Ext.BLANK_IMAGE_URL = '../ext/resources/images/default/s.gif';
	var comboxWithTree = new Ext.form.ComboBox({
        store:new Ext.data.SimpleStore({fields:[],data:[[]]}),
        editable:false,
        allowBlank :false,
        width : 200,
        mode: 'local',
        fieldLabel:'上级菜单',
        triggerAction:'all',
        maxHeight: 200,
        tpl: "<tpl for='.'><div style='height:200px'><div id='tree'></div></div></tpl>",
        selectedClass:'',
        onSelect:Ext.emptyFn
    });
    var tree = new Ext.tree.TreePanel({
         loader: new Ext.tree.TreeLoader({dataUrl:'../'+WebServiceUrl+'?trancode=Tree'}),
         border:false,
         root:new Ext.tree.AsyncTreeNode({text: '功能菜单根目录',id:'1'})
      });
      tree.on('click',function(node){
          comboxWithTree.setValue(node.text);
          Ext.get('pid').dom.value=node.id;
          comboxWithTree.collapse();
      }); 
    comboxWithTree.on('expand',function(){
        tree.render('tree');
      });
	/**
	 * 菜单
	 */
	var storeMenu = new Ext.data.Store({
			baseParams : {
				trancode : 'Menu'
			},
	         proxy: new Ext.data.HttpProxy({
	                url:'../'+WebServiceUrl
	            }),
	            // create reader that reads the project records
	            reader: new Ext.data.JsonReader({root: 'root'},[
	                {name:'name',type:'string'},
	                {name:'id',type:'string'}
	         ])
	});
	storeMenu.load();
	var formPanel = new Ext.FormPanel({
		labelAlign : 'right',
		labelWidth : 80,
		frame : true,
		url :'../'+WebServiceUrl,
		bodyStyle : 'padding:5px 5px 0',
		width : 700,
		items : [{
			layout : 'column',
			items : [{
				columnWidth : .5,
				layout : 'form',
				items : [comboxWithTree,{
					xtype : 'textfield',
					tabIndex : 1,
					maxLength : 16,
					hidden : true,
					hideLabel : true,
					id:'pid',
					anchor : '90%'        
				}]
			}, {
				columnWidth : .5,
				layout : 'form',
				items : [{
					xtype : 'textfield',
					fieldLabel : '菜单名称',
					tabIndex : 1,
					maxLength : 16,
					minLength : 1,
					allowBlank : false,
					name : 'name',
					id:'name',
					anchor : '90%'
				}]
			}]
		}, {
			fieldLabel : '菜单连接',
			xtype : 'textfield',
			maxLength : 50,
			tabIndex : 2,
			allowBlank : false,
			name : 'url',
			id : 'url',
			anchor : '95%'
		}]
	});
	var winid = 'AddMenu';
	var win = new Ext.Window({
		title : '添加菜单',
		width : 720,
		height : 170,
		id : winid,
		layout : 'fit',
		plain : true,
		bodyStyle : 'padding:5px;',
		buttonAlign : 'center',
		resizable : false,
		items : formPanel,
		modal : true,
		buttons : [{
			text : '保存',
			tabIndex : 24,
			handler : function() {
				if (formPanel.form.isValid()) {
					formPanel.form.submit({
						waitTitle : "请稍候",
						waitMsg : '正在保存数据...',
						params : {
							trancode : '90042'
						},
						method : 'Post',
						failure : function(form, action) {
							Ext.MessageBox.alert('操作失败', action.result.message);
						},
						success : function(form, action) {
							if (action.result.success) {
								Ext.MessageBox.alert('操作成功',
										action.result.message);
								ds.load({params:{start:0, limit:App.pageSize}});
								Ext.getCmp(winid).close();
							} else {
								Ext.MessageBox.alert('操作失败',
										action.result.message);
							}
						}
					});
				} else {
					Ext.MessageBox.alert('输入错误', '请输完内容后再保存！');
				}
			}
		}, {
			text : '取消',
			tabIndex : 25,
			handler : function() {
				Ext.getCmp(winid).close();
			}
		}]
	});

	win.show();
};
